package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @author: 夏帮连
 * @date: 2025/06/25
 * @description:
 * @version: 1.0
 */
@Mapper
public interface OrderMapper {
    void insert(Orders order);
    void update(Orders orders);
    @Select("select * from orders where status=#{status} and order_time<=#{localDateTime}")
    List<Orders> getByStatusAndOrderTimeLT(Integer status, LocalDateTime localDateTime);
    @Select("select * from orders where user_id=#{currentId} and number=#{orderNumber}")
    Orders getByUserIdAndNumber(Long currentId, String orderNumber);
    @Select("select * from orders where id=#{id}")
    Orders getById(Long id);

    Page<Orders> page(OrdersPageQueryDTO ordersPageQueryDTO);
    @Select("select IFNULL(count(id), 0) from orders where status=#{status}")
    Integer getByStatus(Integer status);

    Integer countByOrderMap(Map map);

    Double countByTurnOverMap(Map map);

    List<GoodsSalesDTO> getSalesTop10(LocalDateTime begin, LocalDateTime end);
    Integer getOrdersCount(Integer status);
}
